package de.mizi;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import de.mizi.controller.GameController;

public class GamePanel extends JPanel implements KeyListener{
	private JFrame frame;
	private GameController controller;
	
	private static final long serialVersionUID = 1L;
	
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				new GamePanel();
			}
		});
	}
	
	public GamePanel() {
		frame = new JFrame("Roguelike");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		frame.add(this);
		frame.addKeyListener(this);
		controller = new GameController();
		frame.add(controller);
		frame.addKeyListener(controller);

		frame.setResizable(false);
		frame.pack();
		frame.setVisible(true);
	}
	
	@Override
	public void keyPressed(KeyEvent e) {
		if(e.getKeyCode() == KeyEvent.VK_ESCAPE) {
			// Close the application.
			frame.dispose();
		}
	}
	
	@Override
	public void keyReleased(KeyEvent e) {
	}
	
	@Override
	public void keyTyped(KeyEvent e) {
	}
}
